package logic

import (
	"context"
	"fmt"
	"member_srv/models"
	"time"

	"member_srv/internal/svc"
	"member_srv/member"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddMemberLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddMemberLogic {
	return &AddMemberLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddMemberLogic) AddMember(in *member.AddMemberRequest) (*member.AddMemberResponse, error) {
	// todo: add your logic here and delete this line
	t := time.Hour * 24
	y := t * 31
	fmt.Print(int(y))
	n := y * 12
	fmt.Println(n)
	var m models.Member
	m.Title = in.Title
	m.Price = int(in.Price)
	m.Time = int(in.Time)
	err := m.AddMember()
	if err != nil {
		return nil, err
	}

	return &member.AddMemberResponse{MemberId: int64(m.ID)}, nil
}
